package org.springblade.modules.admin.controller.suger;

import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.modules.admin.dto.PlanCheckStatisticsQueryDTO;
import org.springblade.modules.admin.service.IMaintainPlanContentService;
import org.springblade.modules.admin.service.MaintainPlanUserDayCountService;
import org.springblade.modules.admin.vo.CheckStatisticsTrendVO;
import org.springblade.modules.admin.vo.SugarCheckPlanDeptRankingsVO;
import org.springblade.modules.admin.vo.SugarCheckPlanHalfYearVO;
import org.springblade.modules.admin.vo.SugarCheckPlanStatusVO;
import org.springblade.modules.admin.vo.sugar.MaintainTypeDataVO;
import org.springblade.modules.system.service.IDeptService;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Date 9:36 2022/10/12
 * @Description {
 *   数据大屏保养管理
 * }
 * @Author lsay
 **/
@RestController
@RequestMapping("/admin/sugar/check/plan")
@AllArgsConstructor
@Api(value = "数据大屏保养管理", tags = "数据大屏保养管理")
public class SugarCheckPlanController {

	private final IMaintainPlanContentService planContentService;
	private final MaintainPlanUserDayCountService planUserDayCountService;

	/**
	 * 获取今日保养
	 * @return
	 */
	@PostMapping("/today")
	public R<List<Map<String,String>>> getSugarCheckPlanStatus(@RequestBody PlanCheckStatisticsQueryDTO queryDTO){
		return R.data(planContentService.getSugarCheckPlanStatus(queryDTO.getDeptIds()));
	}

	/**
	 * 近6个月保养总览
	 */
	@GetMapping("/half/year")
	public R<List<SugarCheckPlanHalfYearVO>> getSugarCheckPlanHalfYear(){
		return R.data(planContentService.getSugarCheckPlanHalfYear());
	}

	/**
	 * 保养及时排行
	 * @return
	 */
	@PostMapping("/dept/rankings")
	public R<List<SugarCheckPlanDeptRankingsVO>> getSugarCheckPlanDeptRankings(@RequestBody PlanCheckStatisticsQueryDTO queryDTO){
		return R.data(planContentService.getSugarCheckPlanDeptRankings(queryDTO));
	}

	/**
	 * 近30天保养总览
	 */
	@GetMapping("/one/month")
	public R<List<MaintainTypeDataVO>> getSugarCheckPlanOneMonth(){
		return R.data(planContentService.getSugarCheckPlanOneMonth());
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   查询保养执行趋势整体
	 * }
	 * @Date 15:34 2023/9/4
	 * @Param
	 **/
	@PostMapping("/trend/entirety/status")
	public R<List<CheckStatisticsTrendVO>> selectCheckTrendEntiretyStatus(@RequestBody PlanCheckStatisticsQueryDTO queryDTO){
		return R.data(planUserDayCountService.selectCheckTrendEntiretyStatus(queryDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   查询保养时效性趋势整体
	 * }
	 * @Date 15:34 2023/9/4
	 * @Param
	 * @return
	 **/
	@PostMapping("/trend/entirety/timeliness")
	public R<List<CheckStatisticsTrendVO>> selectCheckTrendEntiretyTimeliness(@RequestBody PlanCheckStatisticsQueryDTO queryDTO){
		return R.data(planUserDayCountService.selectCheckTrendEntiretyTimeliness(queryDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   查询保养逾期趋势整体
	 * }
	 * @Date 15:34 2023/9/4
	 * @Param
	 * @return
	 **/
	@PostMapping("/trend/entirety/overdue")
	public R<List<CheckStatisticsTrendVO>> selectCheckTrendEntiretyOverdue(@RequestBody PlanCheckStatisticsQueryDTO queryDTO){
		return R.data(planUserDayCountService.selectCheckTrendEntiretyOverdue(queryDTO));
	}

}
